/*
 * GameFlow.cpp
 *
 *  Created on: Oct 26, 2012
 *      Author: Bhupendra Aole
 */

#include <iostream>
#include "GameFlow.h"

using namespace std;

GameFlow::GameFlow() :
		state( CREATED ), loaded( 0 ) {
}

GameFlow::~GameFlow() {
	scenes.clear();
}

void GameFlow::createScene( string name ) {
	Scene* scene = new Scene( name );
	scenes[name] = scene;
}

void GameFlow::setStartingScene( string name ) {
	startScene = name;
}

void GameFlow::print() {
	map<string, Scene*>::iterator it;

	for ( it = scenes.begin(); it != scenes.end(); it++ )
		cout << (*it).first << " => " << (*it).second->getName() << endl;

	cout << "Start => " << scenes[startScene]->getName() << endl;
}

void GameFlow::start( aole::DXEngine* engine ) {
	state = LOADING;
	Scene *s = scenes[startScene];
	s->load( engine );
	loaded = s;
	state = READY;
}

void GameFlow::render( aole::DXEngine* engine ) {
	if ( state == READY && loaded)
		loaded->render( engine );
}

int GameFlow::getState() {
	return state;
}

